package org.balthie.demo.jvm.classloader.lifecircle;

//https://www.zhihu.com/question/59174759/answer/1854577088
public class SomeClass
{
	static SomeClass inst = new SomeClass(10);
	static long money = 100;
	static final long INIT_COUNT_9 = 9L;
	long appleCount ;
	
	public SomeClass(long price)
	{
		System.out.println("i hava money " + money + " have apple " +appleCount + " inst is " + inst);
		//	i hava money 0 have apple 0 inst is null
		//	首次加载 SomeClass 类对象时， 按声明顺序初始化\成员属性， 运行到这里时money还未初始化 long类型 初始值0	,appleCount 是初始值 0
		this.appleCount = INIT_COUNT_9;
		buyApple(price);
	}
	
	void buyApple(long price)
	{
		System.out.println("spend "+price + " buy an apple ");
		SomeClass.money = SomeClass.money-price;
		System.out.println("left money "+money );
		//	print：	left money -10	
		//	首次加载 SomeClass 类对象时， 按声明顺序初始化static成员属性， 运行到这里时money还未初始化 long类型 初始值0	
		this.appleCount ++;
	}
	
	
}
